# -*- coding: utf-8 -*-
from datetime import timedelta

from jms_hi.dim.dim_tab_order_pick_rate_hi import jms_ods__tab_order_pick_rate_hi
from jms_hi.dwd.oms.dwd_yl_oms_order_tb_exporder_hi import jms_dwd__dwd_yl_oms_order_tb_exporder_hi
from jms_hi.dim.dim_tab_order_source_group_hi import jms_dim__dim_tab_order_source_group_hi
from jms_hi.dwd.oms.dwd_yl_oms_oms_order_hf import jms_dwd__dwd_yl_oms_oms_order_hf
from jms_hi.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dwd__dwd_order_timely_collection_hi = SparkSqlOperator(
    task_id='jms_dwd__dwd_order_timely_collection_hi',
    email=['jokic.wang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    master='yarn',
    name='jms_dwd__dwd_order_timely_collection_hi_{{ execution_date | cst_hour }}',
    sql='jms_hi/dwd/dwd_order_timely_collection_hi/execute.hql',
    pool_slots=3,
    driver_cores=4 , 
    driver_memory='4G' , 
    executor_cores=5 , 
    executor_memory='3G' , 
    num_executors=13 , 
    depends_on_past=True,
    conf={'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
        'spark.dynamicAllocation.maxExecutors'             : 16 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.sql.shuffle.partitions': 900
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 300,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 300  # 最大分区
              },
    yarn_queue='pro_hi',
    execution_timeout=timedelta(minutes=60),
    retries=1,
    sla=timedelta(hours=2), )

jms_dwd__dwd_order_timely_collection_hi << [
    jms_ods__tab_order_pick_rate_hi,
    jms_dwd__dwd_yl_oms_order_tb_exporder_hi,
    jms_dim__dim_tab_order_source_group_hi,
    jms_dwd__dwd_yl_oms_oms_order_hf,
    jms_dim__dim_network_whole_massage
]
